#include "Assert.h"
#include "IVisitor.h"

Assert::Assert(const exprTypePtr& test, const exprTypePtr& msg, int nodeId):
    stmtType(nodeId),
    _test(test),
    _msg(msg)
{
}
    
Assert::~Assert()
{
    
}
    
QString Assert::type() const
{
    return "Assert";
}
    

exprTypePtr Assert::test()
{
    return _test;
}

void Assert::setTest(const exprTypePtr& test)
{
    _test = test;
}

exprTypePtr Assert::msg()
{
    return _msg;
}

void Assert::setMsg(const exprTypePtr& msg)
{
    _msg = msg;
}

    
QString Assert::toString() const
{
    return QString("Assert[test=%1, msg=%2]").
                arg(_test ? _test->toString():"").
                arg(_msg ? _msg->toString():"");
}
    
void Assert::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitAssert(node.dynamicCast<Assert>());
}
    
void Assert::traverse(IVisitor* visitor)
{
    if (_test != NULL)
        _test->accept(visitor, _test);
    if (_msg != NULL)
        _msg->accept(visitor, _msg);
}